package com.jhl.seckill.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller

public class TestController {

    @SentinelResource(value = "aaaa", blockHandler = "deal_testHotKey")
    @GetMapping("/hot")
    @ResponseBody
    public String testHotKey2222(@RequestParam(value = "p1", required = false) String p1,
                                 @RequestParam(value = "p2", required = false) String p2) {
        return "testHotKey~~~~";
    }

    @ResponseBody
    public String deal_testHotKey(@RequestParam("p1") String p1, @RequestParam("p2") String p2, BlockException exception) {
        System.out.println("*******************");
        return "deal_testHotKey！！~~~(*￣︶￣)";// sentinel系统默认的提示: Blocked by Sentinel( flow limiting）
    }

    @SentinelResource(value = "/hello")
    @GetMapping("/hello")
    @ResponseBody
    public String hello() {
        return "hello";
    }
}
